{extend name="public:layout" /}
{block name="title"}搜索属性管理{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content animated fadeInRight">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <li><i class="fa fa-hand-o-right"></i> 搜索属性列表</li>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <button class="btn btn-white" type="button"
                            onclick="updateOrder()">
                        <i class="fa fa-sort"></i>更新排序
                    </button>
                    <a class="btn btn-primary" href="{:url('add')}">
                        <i class="fa fa-plus"></i>&nbsp;添加搜索属性
                    </a>
                </div>
                <div class="clearfix"></div>
            </div>
            <ul class="nav nav-tabs" id="tab_search">
                <li {eq name="query.extend_status" value="1"}class="active"{/eq}><a href="{:url('index',['extend_status'=>1])}">已搜索属性</a></li>
                <li {eq name="query.extend_status" value="0"}class="active"{/eq}><a href="{:url('index',['extend_status'=>0])}">待审核搜索</a></li>
            </ul>
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50">#</th>
                    <th width="100">排序</th>
                    <th width="300">绑定类目</th>
                    <th>搜索属性值</th>
                    <th width="120">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>{$vo.extend_id}</td>
                    <td width="80"> <input type="text" class="form-control list_order"
                                name="list_order[{$vo.extend_id}]" value="{$vo['extend_sort']}"/>
                    </td>
                    <td>{$vo.cid_names}</td>
                    <td>{volist name="vo.extend_value" id="v"}{$v.item_name},{/volist}</td>
                    <td>
                        <a href="{:url('edit',['extend_id'=>$vo['extend_id']])}" {eq name="query.extend_status" value="0"}style="display:none;"{/eq}>编辑</a>
                        <a href="javascript:;" onclick="pass(this);" data-extendid="{$vo.extend_id}" {eq name="query.extend_status" value="1"}style="display:none;"{/eq}>通过</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="确认删除吗？" data-url="{:url('del')}" data-params="extend_id={$vo.extend_id}">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="page-bar">{$list->render()}</div>
            <div class="clearfix"></div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    //更新排序
    function updateOrder() {
        if ($(".list_order").length > 0) {
            var data = $(".list_order").serialize();
            var url = "{:url('updateOrder')}";
            getAjax(url, data, function (data) {
                rePage();
            });
        }
    }
    //通过审核
    function pass(obj){
        var extendid = $(obj).data('extendid');
        getAjax('{:url("pass")}',{extendid:extendid},function (res) {
            if(res.code ==1){
                layer.msg(res.msg,function(){
                    $(obj).closest('tr').remove();
                });
            }
        })
    }
</script>
{/block}